package Servelet;

import sun.security.krb5.Config;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/***
 *@title $NAME
 *@description <TODO description class purpose>
 *@author Tang'ya'kang
 *@VERSION 1.0.0
 *@CREATE 2023/4/26 13:24
 **/
public class Servlet1 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("doPost()被访问");
        String res=request.getMethod();
        System.out.println(res);
        ServletContext servletContext=request.getServletContext();
        ServletConfig servletConfig=getServletConfig();
        System.out.println(servletConfig.getInitParameter("name"));
        System.out.println(servletConfig.getInitParameter("rating"));
        String t=servletContext.getInitParameter("username");
        System.out.println(t);
        System.out.println(servletContext.getContextPath());
        System.out.println(servletContext.getRealPath("/"));
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("doGet()被访问");
        String res=request.getMethod();
        System.out.println(res);
    }

    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println("程序的别名："+config.getServletName());
        System.out.println(config.getInitParameter("name"));
        System.out.println(config.getInitParameter("rating"));
        super.init(config);
    }
}
